package com.example.app.viewmodel

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.AccountBalanceWallet
import androidx.compose.material.icons.rounded.AccountCircle
import androidx.compose.material.icons.rounded.Add
import androidx.compose.material.icons.rounded.Adjust
import androidx.compose.material.icons.rounded.AutoAwesome
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch

//主路由
enum class MainPages(var pageName: String,
    var title: String) {
    HOME("home",
        "主页"),
    LOGIN("login",
        "登录");

    companion object {
        fun values(): Array<MainPages> =
            enumValues<MainPages>()
    }
}
//navbar显示的路由
enum class HomeChild(var pageName: String,
    var title: String,
    var icon: ImageVector) {
    ACCOUNT_LIST("accountList",
        "账目列表",
        Icons.Rounded.AccountBalanceWallet),
    ADD_NEW("addNew",
        "新增",
        Icons.Rounded.Add),
    JUST_TEST_PAGE("testPage",
        "测试",
        Icons.Rounded.Adjust),
    ME("me",
        "我的",
        Icons.Rounded.AccountCircle);

    companion object {
        fun values(): Array<HomeChild> {
            return enumValues<HomeChild>()
        }
    }
}

enum class AddNewChild(var pageName: String,
    var title: String) {
    ADD_RECORD("addRecord",
        "新增账目")
}

class RouteViewModel : ViewModel() {

    var _curPage = MutableStateFlow<MainPages>(MainPages.HOME)
    var curPage = _curPage.asStateFlow()
    fun flowUpdate_curPage(value: MainPages) {
        _curPage.update {
            value
        }
    }
    var _curHomeChild = MutableStateFlow<HomeChild>(HomeChild.ACCOUNT_LIST)
    var curHomeChild = _curHomeChild.asStateFlow()
    fun flowUpdate_curHomeChild(value: HomeChild) {
        _curHomeChild.update {
            value
        }
    }
    var _curAddNewChild = MutableStateFlow<AddNewChild?>(null)
    var curAddNewChild = _curAddNewChild.asStateFlow()
    fun flowUpdate_curAddNewChild(value: AddNewChild?) {
        _curAddNewChild.update {
            value
        }
    }
}


